<template>
  <div class="swiper">
    <swiper :options="swiperOption" v-if="showSwiper">
    <!-- slides -->
      <swiper-slide v-for="item in list" :key="item.id">
        <img :src="item.imgUrl" alt="" width="100%">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
export default {
  name:'Swiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  components: {
    swiper,
    swiperSlide
  },
  computed: {
    showSwiper () {
      return this.list !== undefined &&this.list.length > 0
    }
  }
}
</script>

<style lang="stylus" scoped>
.swiper >>> .swiper-pagination-bullet-active
  background #fff
.swiper
  overflow hidden
  width 100%
  height 0
  padding-bottom 31.25%
</style>